﻿@model IEnumerable<BBICMS.Application.ViewModels.ColorVM>
@{
    ViewBag.Title = EntityNames.Color;
    ViewBag.PageTitle = ViewBag.Title + "_内容";
}



<div class="panel panel-default">
    <header class="panel-heading">
        <div class="text-right">
            <a class="btn btn-primary" href="@Url.Action("AddColor")"><i class="glyphicon glyphicon-plus"></i> @string.Format("{0}{1}", Buttons.Add, EntityNames.Color)</a>
        </div>
    </header>


    <div class="table-responsive">
        <table class="table table-hover table-vmiddle">
            <thead>
                <tr>
                    <th>
                       颜色
                    </th>
                    <th>
                        颜色名称
                    </th>
                    <th>
                        激活？
                    </th>
                    <th>
                        操作
                    </th>
                </tr>
            </thead>
            <tbody>
                @foreach (var item in Model)
                {
                    <tr class="item-container">
                        <td>
                            <div style="width:90px;height:30px;background-color:@item.Value"></div>
                        </td>

                        <td>
                            @item.Name
                        </td>



                        <td>
                            @if (item.Active)
                            {
                                <a href="#" data-url="@Url.Action("IsActiveColor", new {id = item.Id})" class="active-item" title="锁定">
                                    <i class="fa fa-check text-success"></i>
                                </a>

                            }
                            else
                            {
                                <a href="#" data-url="@Url.Action("IsActiveColor", new {id = item.Id})" class="active-item" title="解锁">
                                    <i class="fa fa-remove text-danger"></i>
                                </a>
                            }
                        </td>
                        <td>
                            <a href="@Url.Action("EditColor", new { Id = item.Id })" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i></a>
                            <a href="@Url.Action("DeleteColor", new { Id = item.Id })" class="btn btn-xs btn-danger delete-item"><i class="glyphicon glyphicon-trash"></i></a>
                        </td>
                    </tr>
                }

            </tbody>

        </table>



    </div>


    <footer class="panel-footer"></footer>
</div>

<form id="anti-form" method="post">
    @Html.AntiForgeryToken()
</form>
<!-- end main container -->
@section footer {

    <script>

        $(function () {

            //锁定 激活
            $('.active-item').click(function (e) {

                e.preventDefault();
                var url = $(this).attr('data-url'), title = $(this).attr('title'), that = $(this);
                Common.ActiveItem(url, title, that);

            });



            //删除数据
            $('.delete-item').click(function (e) {
                e.preventDefault();
                var url = $(this).attr('href'), that = $(this), title = '@string.Format("删除{0}",EntityNames.Category)';

                bootbox.setLocale("zh_CN");

                bootbox.confirm("是否确定删除该项？", function (result) {
                    if (result) {
                        Common.DeleteItem(url, title, that);
                    }
                });
            });



        });
    </script>

}